package com.example.animal.controller;

import com.example.animal.mapper.*;
import com.example.animal.model.*;
import com.example.animal.model.Personnel;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("index")
public class IndexController {

    @Resource
    AnimalMapper animalMapper;
    @Resource
    PersonnelMapper personnelMapper;
    @Resource
    AccessRecordMapper accessRecordMapper;
    @Resource
    LaboratoryMapper laboratoryMapper;
    @Resource
    SecurityMapper securityMapper;
    @Resource
    TrainingCourseMapper trainingCourseMapper;
    @Resource
    VisitorInfoMapper visitorInfoMapper;

    @RequestMapping("hello")
    public VisitorInfo hello(
            @RequestParam(name = "id", required = false, defaultValue = "0") Long id
    ) {

//        User user = new User();
//        user.setId(1);
//        user.setName("Dennis");
//        user.setAge(22);
        Personnel personnel = personnelMapper.getPersonnelById(id);
        System.out.println(personnel);
        Animal animal = animalMapper.getAnimalInfoByAnimalID(id);
        System.out.println(animal);
        AccessRecord accessRecord = accessRecordMapper.getAccessRecordByRecordID(id);
        System.out.println(accessRecord);
        Laboratory laboratory = laboratoryMapper.getLaboratoryByLaboratoryID(id);
        System.out.println(laboratory);
        Security security = securityMapper.getSecurityBySecurityID(id);
        System.out.println(security);
        TrainingCourse trainingCourse = trainingCourseMapper.getTrainingCourseByCourseID(id);
        System.out.println(trainingCourse);
        VisitorInfo visitorInfo = visitorInfoMapper.getVisitorInfoByVisitorInfoID(id);
        System.out.println(visitorInfo);
        return visitorInfo;
    }

    @RequestMapping("getAnimalList")
    public List<Animal> getAnimalList() {
        List<Animal> animals = animalMapper.getAnimalList();
        System.out.println(animals);
        return animals;
    }
}
